// 统一管理权限相关接口
import http from '@/utils/request'

import type { UserResponseType, User, UserAddResponseType, UserAllResponseType, setUserRoleType } from './type.ts'

// 通过枚举统一管理接口
enum API {
  USERLIST_URL = '/admin/acl/user/',
  USERSAVE_URL = '/admin/acl/user/save',
  USERUPDATE_URL = '/admin/acl/user/update',
  GETALLUSER_URL = '/admin/acl/user/toAssign/',
  SETROLE_URL = '/admin/acl/user/doAssignRole/',
  REMOVEUSER_URL = '/admin/acl/user/remove/',
  REMOVEUSERLIST_URL = '/admin/acl/user/batchRemove',
}

// 批量删除用户
export const removeUserListAPI = (idList: (number | string)[]) => http.delete<any, any>(API.REMOVEUSERLIST_URL, {
  data: idList
})

// 删除用户
export const removeUserAPI = (id: number | string) => http.delete<any, any>(API.REMOVEUSER_URL + id)

// 给用户分配角色
export const setUserRoleAPI = (data: setUserRoleType) => http.post<any, any>(API.SETROLE_URL, data)

// 获取全部职位以级当前用户拥有的职位
export const getUserAllAPI = (adminId: number | string) => http.get<any, UserAllResponseType>(API.GETALLUSER_URL + adminId)


// 获取用户行号信息
export const getUserInfoListAPI = (page: number, limit: number, username: string) => http.get<any, UserResponseType>(API.USERLIST_URL + `${page}/${limit}/?username=${username}`)

// 新增用户信息
export const addUserInfoAPI = (data: User) => http.post<any, UserAddResponseType>(API.USERSAVE_URL, data)

// 编辑用户信息
export const updateUserInfoAPI = (data: User) => http.put<any, UserAddResponseType>(API.USERUPDATE_URL, data)